home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 July / EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso / recent1 / wwwcount2.3bin.lha / Gen-conf < prev    next >
Text File  |  1997-05-19  |  12KB  |  490 lines

  1. #!/bin/sh
  2. ###
  3. # $Revision: 2.3 $
  4. # $Date: 1996/05/03 02:20:22 $
  5. #
  6. # Automatically generate  the conter configuration file
  7. ###
  8. Version="2.3"
  9. ConfFile="count.cfg"
  10. nick=0
  11. ignc=0
  12. alfc=0
  13. strict=0
  14. rgb=0
  15.  
  16. (echo "hi there\c" ; echo " ") >.echotest
  17. if grep c .echotest >/dev/null 2>&1 ; then
  18. n='-n'
  19. c=''
  20. else
  21. n=''
  22. c='\c'
  23. fi
  24. rm -f .echotest >/dev/null 2>&1
  25.  
  26. cat << EOSI
  27.     Welcome to the conf file generation procedure of Count $Version
  28.  
  29.     This program creates a workable conf file for your host only, you have
  30.     to edit it by hand if you want to add other hosts. The file will have
  31.     enough comments in it to help you out. You also have to hand edit it
  32.     if you want to use netmasks to mask out a entire network or a specific
  33.     range of hosts in a network.
  34.  
  35.     First of all you must know your 
  36.         1) fully qualified domain name (FQDN), for example,
  37.             if your hostname is foo and your domain name is foobar.com,
  38.             then your FQDN is
  39.             foo.foobar.com
  40.  
  41.         2) IP address of your host, for example, 
  42.             192.165.155.2 
  43.  
  44.         3) If your host has any nickname defined, for example,
  45.             www.foobar.com. The nick name also has to be FQDN.
  46.  
  47.         4) If you want to allow automatic datafile creation (bad thing).
  48.  
  49.         5) If you want to run the counter in strict mode.
  50.  
  51.         6) If you want to ignore access hits from your own host.
  52.  
  53. EOSI
  54.  
  55. echo $n "Continue [y|n]$c? "
  56. read answer
  57.  
  58. if [ .$answer = . ]
  59. then
  60.     answer=x 
  61. fi
  62.     until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  63.     do
  64.         echo $n "Continue [y|n]$c? "
  65.         read answer
  66.             if [ .$answer = . ]
  67.             then
  68.                 answer=x
  69.             fi
  70.     done   
  71.     
  72.     case $answer in
  73.         y|Y)
  74. ######
  75. # Enter hostname  --Starts
  76. #####
  77. cat<<EOE
  78.         
  79.     No Error checking will be done with your hostname, therfore,
  80.     you better make sure you are entering the fully qualifed domain name.
  81.           
  82. EOE
  83.     echo $n "* Enter your fully qualified domain name [no default]:$c "
  84.     read hostname     
  85.    host=`echo $hostname|awk -F. '{print $1}'`
  86.    dom1=`echo $hostname|awk -F. '{print $2}'`
  87.    dom2=`echo $hostname|awk -F. '{print $3}'`
  88.     until [ .$hostname != . -a .$host != . -a .$dom1 != . -a .$dom2 != . ]
  89.     do
  90.         echo $n "* Enter your fully qualified domain name [no default]:$c "
  91.         read hostname
  92.         host=`echo $hostname|awk -F. '{print $1}'`
  93.         dom1=`echo $hostname|awk -F. '{print $2}'`
  94.         dom2=`echo $hostname|awk -F. '{print $3}'`
  95.     done
  96.  
  97. ######
  98. # Enter hostname  --Ends
  99. #####
  100.  
  101. ######
  102. # Enter ip address  --Starts
  103. #####
  104. cat<<EOE
  105.  
  106.     No Error checking will be done with your IP address, therfore,
  107.     you better make sure you are entering the correct IP address.
  108.  
  109. EOE
  110.     echo $n "* Enter your IP address [no default]:$c "
  111.     read ipaddress
  112.     oct1=`echo $ipaddress|awk -F. '{print $1}'`
  113.     oct2=`echo $ipaddress|awk -F. '{print $2}'`
  114.     oct3=`echo $ipaddress|awk -F. '{print $3}'`
  115.     oct4=`echo $ipaddress|awk -F. '{print $4}'`
  116.     until [ .$ipaddress != . -a .$oct1 != . -a .$oct2 != .\
  117.         -a .oct3 != . -a .$oct4 != . ]
  118.     do   
  119.         echo $n "* Enter your IP address [no default]:$c "
  120.         read ipaddress
  121.     oct1=`echo $ipaddress|awk -F. '{print $1}'`
  122.     oct2=`echo $ipaddress|awk -F. '{print $2}'`
  123.     oct3=`echo $ipaddress|awk -F. '{print $3}'`
  124.     oct4=`echo $ipaddress|awk -F. '{print $4}'`
  125.     done
  126.  
  127. ######
  128. # Enter ip address  --Ends
  129. #####
  130.  
  131. ######
  132. # ask for nick --Starts
  133. #####
  134.    echo ""
  135.    echo $n "* Does your host have any nickname [y|n]:$c? "
  136.    read answer  
  137.    if [ .$answer = . ]  
  138.    then
  139.         answer=x
  140.    fi
  141.    until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  142.    do
  143.         echo $n "* Does your host have any nickname (FQDN) [y|n]:$c? "
  144.         read answer
  145.         if  [ .$answer = . ]
  146.         then
  147.             answer=x
  148.         fi
  149.    done
  150.  
  151.     case $answer in
  152.         y|Y)
  153.             nick=1
  154.             echo $n "* Enter your host's nickname (FQDN) [no default]:$c "
  155.             read nickname
  156.             nhost=`echo $nickname|awk -F. '{print $1}'`
  157.             ndom1=`echo $nickname|awk -F. '{print $2}'`
  158.             ndom2=`echo $nickname|awk -F. '{print $3}'`
  159.     until [ .$nickname != . -a .$nhost != . -a .$ndom1 != . -a .$ndom2 != . ]
  160.     do
  161.         echo $n "* Enter your host's nickname [no default]:$c "
  162.         read nickname
  163.         nhost=`echo $nickname|awk -F. '{print $1}'`
  164.         ndom1=`echo $nickname|awk -F. '{print $2}'`
  165.         ndom2=`echo $nickname|awk -F. '{print $3}'`
  166.     done
  167.         ;;
  168.         n|N)
  169.         ;;
  170.         *)
  171.             echo "Illegal choice"
  172.      esac
  173.     until [ .$hostname != . -a .$host != . -a .$dom1 != . -a .$dom2 != . ]
  174.     do
  175.         echo $n "* Enter your fully qualified domain name [no default]:$c "
  176.         read hostname
  177.         host=`echo $hostname|awk -F. '{print $1}'`
  178.         dom1=`echo $hostname|awk -F. '{print $2}'`
  179.         dom2=`echo $hostname|awk -F. '{print $3}'`
  180.     done
  181. ######
  182. # ask for nick --Ends
  183. #####
  184.         ;;
  185.         n|N)
  186.             echo "Exiting..Better luck next time!"
  187.             exit 1
  188.         ;;
  189.  
  190.         *)
  191.             echo ""
  192.             echo "Illegal choice"
  193.      esac
  194.  
  195.  
  196. ###
  197. # allow file creation?
  198. ###
  199. cat<<EOAF
  200.     
  201.     Now you need to decide if you will allow the users to create datafiles
  202.     for them automatically. If you allow, the counter datafile will be
  203.     created for the user if it does not exist and a pre-determined counter
  204.     number will be inserted to it. If you do not allow, you have to create
  205.     the datafile for each user, provided that the data diectory has proper
  206.     write permission.  
  207.  
  208.     Allowing users to create datafile is very convenient, as you do not
  209.     have to be asked all the time when someone decides to use the counter.
  210.     But the dark side of this is, anyone will be able create datafiles in
  211.     the data directory. The decision is yours.
  212.  
  213. EOAF
  214. echo $n "* Do you want to allow automatic file creation [[y|n]$c? "
  215. read answer
  216. if [ .$answer = . ]
  217. then
  218.     answer=x
  219. fi
  220. until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ] 
  221. do
  222.     echo $n "* Do you want to allow automatic file creation [[y|n]$c? "
  223.         read answer
  224.             if [ .$answer = . ]
  225.             then
  226.                 answer=x
  227.             fi
  228.     done
  229.     
  230.     case $answer in
  231.         y|Y)
  232.             alfc=1
  233.         ;;
  234.  
  235.         n|N)
  236.             alfc=0
  237.         ;;
  238.  
  239.         *)
  240.             echo ""
  241.             echo "Illegal choice"
  242.      esac
  243.  
  244. ##
  245. # compile in strict mode or not
  246. ###
  247. cat <<EOSM
  248.  
  249.     Now you need to decide if you want to compile the program in strict   
  250.     mode. If you compile the program in strict mode, the browsers which
  251.     do not return the environment variable HTTP_REFERER, will not be
  252.     served, that is no access hit will be recorded, no time or date
  253.     will be displayed. Instead, a string 888888 will be displayed. 
  254.     
  255.     The strict mode ensures that your counter data file can not be messed
  256.     by accesing the counter remotely from a browser which does not return
  257.     that variable. Note, good browsers like netscape returns this
  258.     variable. Other browsers e.g. Mosaic does not return this variable in
  259.     IMG GET method at this time.  This strict mode is experimental at this
  260.     time!
  261.  
  262. EOSM
  263. echo $n "* Do you want the program to run in strict mode [[y|n]$c? "
  264. read answer
  265. if [ .$answer = . ]
  266. then
  267.     answer=x
  268. fi
  269. until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ] 
  270. do
  271. echo $n "* Do you want the program to run in strict mode [[y|n]$c? "
  272.         read answer
  273.             if [ .$answer = . ]
  274.             then
  275.                 answer=x
  276.             fi
  277.     done
  278.     
  279.     case $answer in
  280.         y|Y)
  281.             strict=1
  282.         ;;
  283.  
  284.         n|N)
  285.             strict=0
  286.         ;;
  287.  
  288.         *)
  289.             echo ""
  290.             echo "Illegal choice"
  291.      esac
  292.  
  293. ########
  294. echo $n "* Do you want to ignore access hits from your own host [y|n]$c? "
  295. read answer
  296.         
  297. if [ .$answer = . ]
  298. then
  299.     answer=x
  300. fi
  301.     until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  302.     do
  303.         echo $n "Do you want to ignore access from your own host [y|n]$c? "
  304.         read answer
  305.             if [ .$answer = . ]
  306.             then
  307.                 answer=x
  308.             fi
  309.     done
  310.       
  311.     case $answer in
  312.         y|Y)
  313.             ignc=1
  314.         ;;
  315.  
  316.         n|N)
  317.             ignc=0
  318.         ;;
  319.  
  320.         *)
  321.             echo ""
  322.             echo "Illegal choice"
  323.      esac
  324.  
  325. ##
  326. # allow to use color name datase? --starts
  327. ##
  328. cat<<EORG
  329.  
  330.     Ok, do you want the users to use the file rgb.txt for color name
  331.     lookup? It is very inefficient to search this file every time the
  332.     web page is loaded. If you answer yes, the color name
  333.     will be looked up and used. If you answer no, the color will be
  334.     looked up but instead of the counter image, the RGB value will
  335.     be displayed and the user will be asked to use the RGB value
  336.     instead. This will prevent users to use this file. However,
  337.     the convenience of allowing to use rgb.txt file is that color name e.g,
  338.     red, gold etc.  can be used instead of cryptic red, green and blue
  339.     components of the color.
  340.     
  341. EORG
  342. echo $n "* Allow using the rgb.txt file [y|n]$c? "
  343. read answer
  344.         
  345. if [ .$answer = . ]
  346. then
  347.     answer=x
  348. fi
  349.     until [ $answer = "y" -o $answer = "Y" -o $answer = "n" -o $answer = "N" ]
  350.     do
  351.         echo $n "*  Allow using the rgb.txt file [y|n]$c? "
  352.         read answer
  353.             if [ .$answer = . ]
  354.             then
  355.                 answer=x
  356.             fi
  357.     done
  358.       
  359.     case $answer in
  360.         y|Y)
  361.             rgb=1
  362.         ;;
  363.  
  364.         n|N)
  365.             rgb=0
  366.         ;;
  367.  
  368.         *)
  369.             echo ""
  370.             echo "Illegal choice"
  371.      esac
  372.  
  373. ##
  374. # allow to use color name datase? --ends
  375. ##
  376. ##########
  377.  
  378. d=`date`
  379. wh=`whoami`
  380. hn=`hostname`
  381. cat<<IGH>$ConfFile
  382. #######
  383. # configuratin file for Count $Version
  384. # Automatically generated from user input by the script Gen-conf
  385. # Created on: $d
  386. # Edit by hand, if you need to add something
  387. ##############################################
  388. ####
  389. # BLOCK 1
  390. # Allow automatic datafile creation or not
  391. # it's a required block. 1 means allow, 0 means do not allow.
  392. ####
  393. IGH
  394. if [ $alfc -eq 1 ]
  395. then
  396.    echo "{" >> $ConfFile
  397.    echo "1" >> $ConfFile
  398.    echo "}" >> $ConfFile 
  399. else
  400.    echo "{" >> $ConfFile
  401.    echo "0" >> $ConfFile
  402.    echo "}" >> $ConfFile 
  403. fi
  404. cat<<STM>>$ConfFile
  405. ###
  406. # BLOCK 2
  407. # run the program in strict mode or not.
  408. # it's a required block. 1 means strict, 0 means not strict.
  409. ###
  410. STM
  411. if [ $strict -eq 1 ]
  412. then
  413.    echo "{" >> $ConfFile
  414.    echo "1" >> $ConfFile
  415.    echo "}" >> $ConfFile 
  416. else
  417.    echo "{" >> $ConfFile
  418.    echo "0" >> $ConfFile
  419.    echo "}" >> $ConfFile 
  420. fi
  421.  
  422. cat<<BLOCK3>>$ConfFile
  423. ####
  424. # BLOCK 3
  425. # Allow to use RGB color database. 0 means allow, 1 means don't
  426. # convenient to use because colorname e.g., red, gold etc can
  427. # be used instead of rgb components of the color, however it's
  428. # very inefficient to lookup.
  429. ####
  430. BLOCK3
  431. if [ $rgb -eq 1 ]
  432. then
  433.     echo "{" >> $ConfFile
  434.     echo "1" >> $ConfFile
  435.     echo "}" >> $ConfFile
  436. else
  437.     echo "{" >> $ConfFile
  438.     echo "0" >> $ConfFile
  439.     echo "}" >> $ConfFile
  440. fi
  441. cat<<IGH2>>$ConfFile
  442. ####
  443. # BLOCK 4
  444. # Ignore count block, you might want to ignore the local sites.
  445. # If you do not want to ignore any hosts from
  446. # counting, just put { on one line and } on the next line but make sure
  447. # the braces exist!
  448. # It's a required block.
  449. ######
  450. # netmasks can be used to ignore a entire network or a specific
  451. # range of hosts in the network. Read the counter documentation to
  452. # know about netmasks.
  453. IGH2
  454. if [ $ignc -eq 1 ]
  455. then
  456.     echo "{" >> $ConfFile
  457.     echo "$ipaddress" >> $ConfFile
  458.     echo "}" >> $ConfFile
  459. else
  460.     echo "{" >> $ConfFile
  461.     echo "}" >> $ConfFile
  462. fi
  463. # generate auth block
  464. cat<<EOBL>>$ConfFile
  465. ####
  466. # BLOCK 5
  467. # Auth block
  468. # All possible names and IP addresses by which your host can be referred.
  469. # These hosts can access the counter remotely or locally. Host running
  470. # the http server must exist here.
  471. ##
  472. EOBL
  473. echo "{" >> $ConfFile
  474. echo "$hostname" >> $ConfFile
  475. echo "$host" >>$ConfFile
  476. echo "$ipaddress" >> $ConfFile
  477. if [ $nick -eq 1 ]
  478. then
  479.     echo "$nickname" >> $ConfFile
  480.     echo "$nhost" >>$ConfFile
  481. fi
  482. echo "}" >>$ConfFile
  483.  
  484. cat <<EOCF
  485.  
  486.     Created conf file "$ConfFile"
  487.     Please look at it, you might want to edit it!
  488.  
  489. EOCF
  490.